const path = require("path")
module.exports = {
  chainWebpack: (config) => {
    const svgRule = config.module.rule("svg")
    // 清除已有的所有 loader,否则接下来的 loader 会附加在该规则现有的 loader 之后。
    svgRule.uses.clear()
    svgRule
      .test(/\.svg$/)
      .include.add(path.resolve(__dirname, "./src/assets/icons")) // 配置icons的目录
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "icon-[name]",
      })
    const fileRule = config.module.rule("file")
    fileRule.uses.clear()
    fileRule
      .test(/\.svg$/)
      .exclude.add(path.resolve(__dirname, "./src/assets/icons")) // 配置icons的目录
      .end()
      .use("file-loader")
      .loader("file-loader")
  },
  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          "primary-color": "#13c2c2",
          "layout-color": "#9867f7",
        },
        javascriptEnabled: true,
      },
    },
  },

  publicPath: "./",
  indexPath: "index.html",
  lintOnSave: false,
  assetsDir: "spa_static",
  devServer: {
    // productionGzipExtensions: ['js', 'css', 'vue'],
    host: "localhost",
    port: 8085,
    proxy: {
      "/api": {
        // target: "http://192.168.142.231:7777",
        target: "http://192.168.138.112:7777",
        changeOrigin: true,
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },
}
